SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 50949: Using the position rather than the name of a variable in a GROUP BY clause might result in an error

DetailsAboutRate It

An error might occur when you run an SQL procedure query when the following conditions exist:

  • An SQL view includes the creation of a new variable as a result of a summary function.
  • The view is used in a subsequent query where it is joined to another table using an outer join and the new variable is used in the GROUP BY clause.
  • The variable position in the SELECT clause rather than the variable name is used in the GROUP BY clause.
The error might look similar to the following:
ERROR: GROUP BY clause contains a summary function, which is not allowed. ERROR: Summary functions are restricted to the SELECT and HAVING clauses only.
Submitting a query similar to the following might result in the above error:
proc sql; create view v2 as select x, y, max(z) as mz from t2 group by x, y; quit; proc sql; create table results as select t1.x, sum(t1.y) as sy, v2.mz from t1 left join v2 on t1.x=v2.x group by 3; quit;
The only workaround is to use the variable name rather than its position in the GROUP BY clause.

Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SASz/OS9.3 TS1M29.4 TS1M1
Z649.3 TS1M29.4 TS1M1
Microsoft® Windows® for x649.3 TS1M29.4 TS1M1
Microsoft Windows 8 Enterprise 32-bit9.3 TS1M29.4 TS1M1
Microsoft Windows 8 Enterprise x649.3 TS1M29.4 TS1M1
Microsoft Windows 8 Pro 32-bit9.3 TS1M29.4 TS1M1
Microsoft Windows 8 Pro x649.3 TS1M29.4 TS1M1
Microsoft Windows Server 2003 Datacenter Edition9.3 TS1M2
Microsoft Windows Server 2003 Enterprise Edition9.3 TS1M2
Microsoft Windows Server 2003 Standard Edition9.3 TS1M2
Microsoft Windows Server 2003 for x649.3 TS1M2
Microsoft Windows Server 20089.3 TS1M2
Microsoft Windows Server 2008 R29.3 TS1M29.4 TS1M1
Microsoft Windows Server 2008 for x649.3 TS1M29.4 TS1M1
Microsoft Windows Server 2012 Datacenter9.3 TS1M29.4 TS1M1
Microsoft Windows Server 2012 Std9.3 TS1M29.4 TS1M1
Microsoft Windows XP Professional9.3 TS1M2
Windows 7 Enterprise 32 bit9.3 TS1M2
Windows 7 Enterprise x649.3 TS1M29.4 TS1M1
Windows 7 Home Premium 32 bit9.3 TS1M2
Windows 7 Home Premium x649.3 TS1M2
Windows 7 Professional 32 bit9.3 TS1M2
Windows 7 Professional x649.3 TS1M29.4 TS1M1
Windows 7 Ultimate 32 bit9.3 TS1M2
Windows 7 Ultimate x649.3 TS1M2
Windows Vista9.3 TS1M2
Windows Vista for x649.3 TS1M2
64-bit Enabled AIX9.3 TS1M29.4 TS1M1
64-bit Enabled HP-UX9.3 TS1M29.4 TS1M1
64-bit Enabled Solaris9.3 TS1M29.4 TS1M1
HP-UX IPF9.3 TS1M29.4 TS1M1
Linux9.3 TS1M29.4 TS1M1
Linux for x649.3 TS1M29.4 TS1M1
Solaris for x649.3 TS1M29.4 TS1M1
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.